using System;
using System.Collections;
using System.Text;

namespace Msrp.Message
{
    /* Official syntax
     * MSRP-URI = msrp-scheme "://" authority ["/" session-id] ";" transport *( ";" URI-parameter)
     * msrp-scheme = "msrp" / "msrps"
     * session-id = 1*( unreserved / "+" / "=" / "/" )
     * transport = "tcp" / 1*ALPHANUM
     * URI-parameter = token ["=" token]
     * authority   = [ userinfo "@" ] host [ ":" port ]
     * unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"
     * 
     * Example msrp://user@superhost.com:12345/qw+lh~-_ljh;tcp;paramName=paramValue;paramName1=paramValue1
     */

    public class Uri: System.Uri
    {
        public Uri(String fUri):base(fUri)
        {
            parseUnparsedPart();
        }

        public String SessionId
        {
            get { return m_sessionId; }
        }
        public String Transport
        {
            get { return m_transport; }
        }


        private void parseUnparsedPart()
        {
            AbsolutePath.TrimStart("/".ToCharArray());
            string[] tokens = AbsolutePath.Split(";".ToCharArray());
            if (tokens[0].Length != 0)
            {
                m_sessionId = tokens[0];
            }
            m_transport = tokens[1];
        }


        //private String m_host;
        //private int m_port;
        private String m_sessionId = "";
        private String m_transport;
        private ArrayList m_paramList = new ArrayList();

    }
}
